﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Digitalmes.Application;
using Digitalmes.Scada.Management;

namespace Digitalmes.Scada.WebApi;

/// <summary>
/// 设备状态 API
/// </summary>
[ApiExplorerSettings(GroupName = "scada")]
[AllowAnonymous]
public sealed class ScadaEquipStateApi : IDynamicWebApiService, ITransientDependency
{
    private readonly EquipmentStateSnapshotManager _equipmentStateSnapshotManager;

    public ScadaEquipStateApi(EquipmentStateSnapshotManager equipmentStateSnapshotManager)
    {
        _equipmentStateSnapshotManager = equipmentStateSnapshotManager;
    }

    /// <summary>
    /// 获取所有设备状态
    /// </summary>
    [HttpGet]
    public dynamic GetAllStates()
    {
        return _equipmentStateSnapshotManager.GetAllSnapshot();
    }
}
